const models = require('../../models')

class Admin{
    static async adminLogin(ctx){
        const info = ctx.request.body;
        console.log(info)
        const admin = await models.admins.findOne({
            where: {
                number: info.number
            }
        })
        if(!admin){
            ctx.response.status = 200;
            ctx.response.body = {
                code: 501,
                msg: '账号不存在！'
            }
        }else if(info.password === admin.password){
            ctx.response.status = 200;
            ctx.response.body = {
                code: 200,
                msg: '登录成功',
                data: admin
            }
        }else{
            ctx.response.status = 200;
            ctx.response.body = {
                code: 501,
                msg: '密码不正确'
            }
        }
    }
}

module.exports = Admin;